$(document).ready(function(){
	function loadLog() {
	
			var oldScrollHeight = $("#groupBox").attr("scrollHeight") - 20;
			$.ajax({
				url: "includes/message_group.php",
				cache: false,
				success: function(html) {
					$("#groupBox").html(html);
					var newscrollHeight = $("#groupBox").attr("scrollHeight") - 20;
					if(newscrollHeight>oldScrollHeight) {
						$("#groupBox").animate({ scrollTop: newscrollHeight}, 'normal');
					}
				}
			});
			
		setInterval(loadLog, 1000);
		}
});
